using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class tbHinhAnhBUS
    {
        public static void Insert(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            haDAL.Insert(hinhanh);
        }
        public static void Update(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL haDAl = new tbHinhAnhDAL();
            haDAl.Update(hinhanh);
        }
        public static void Delete(int iD)
        {
            tbHinhAnhDAL haDAl = new tbHinhAnhDAL();
            haDAl.Delete(iD);
        }
        public static tbHinhAnhCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            return haDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhAnhCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            return haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaSP.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbHinhAnh GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbHinhAnhColumns.MaHA.ToString(), Condition.EQUAL, iD);
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            tbHinhAnhCollection haCollection = haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaHA.ToString(), OrderDirection.ASC.ToString(), out total);
            if (haCollection.Count > 0)
                return haCollection[0];
            return null;
        }

////        public static tbHinhAnh GetByMaSP(int iD)
////        {
////            int total = 0;
////            Criteria cri = new Criteria();
////            cri.add(Condition.AND, tbHinhAnhColumns.MaSP.ToString(), Condition.EQUAL, iD);
////            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
////            tbHinhAnhCollection haCollection = haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaHA.ToString(), OrderDirection.ASC.ToString(), out total);
////            if (haCollection.Count > 0)
////                return haCollection[0];
////            return null;
////        }

        public static int imageFirst(int MaSanPham)
        {
            tbHinhAnhDAL hinhAnh = new tbHinhAnhDAL();
            return hinhAnh.imageFirst(MaSanPham);
        }

////    }
////}
//        //public static tbHinhAnhCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
//        //{
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
//        //}
//        public static tbHinhAnhCollection GetAll()
//        {
//            int total = 0;
//            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//            return haDAL.Get("where 1=1", 0, 0, tbHinhAnhColumns.MaSP.ToString(), "ASC", out total);
//        }
//        public static tbHinhAnh GetByID(int iD)
//        {
//            int total = 0;
//            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//            tbHinhAnhCollection haCollection = haDAL.Get("where " + tbHinhAnhColumns.MaSP.ToString() + "=" + iD.ToString(), 0, 0, tbHinhAnhColumns.MaSP.ToString(), "ASC", out total);
//            if (haCollection.Count > 0)
//                return haCollection[0];
//            return null;
//        }
//        //public static int imageFirst(int MaSanPham)
//        //{
//        //    tbHinhAnhDAL hinhAnh = new tbHinhAnhDAL();
//        //    return hinhAnh.imageFirst(MaSanPham);
//        //}
//        //public static tbHinhAnhCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
//        //{
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
//        //}
//        //public static tbHinhAnhCollection GetAll()
//        //{
//        //    int total = 0;
//        //    Criteria cri = new Criteria();
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaHA.ToString(), OrderDirection.ASC.ToString(), out total);
//        //}
//        //public static tbHinhAnh GetByID(int iD)
//        //{
//        //    int total = 0;
//        //    Criteria cri = new Criteria();
//        //    cri.add(Condition.AND, tbHinhAnhColumns.MaHA.ToString(), Condition.EQUAL, iD);
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    tbHinhAnhCollection haCollection = haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaHA.ToString(), OrderDirection.ASC.ToString(), out total);
//        //    if (haCollection.Count > 0)
//        //        return haCollection[0];
//        //    return null;
//        //}
//        //public static tbHinhAnhCollection GetLimited(int number)
//        //{
//        //    int total = 0;
//        //    Criteria cri = new Criteria();
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get(cri.Criter, 1, number, tbHinhAnhColumns.MaHA.ToString(), OrderDirection.DESC.ToString(), out total);
//        //}
//        //public static tbHinhAnhCollection GetPromotion(int number)
//        //{
//        //    int total = 0;
//        //    Criteria cri = new Criteria();
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get(cri.Criter, 1, number, tbHinhAnhColumns.MaHA.ToString(), OrderDirection.DESC.ToString(), out total);
//        //}

//        //public static tbHinhAnh GetByMaSP(int iD)
//        //{
//        //    int total = 0;
//        //    Criteria cri = new Criteria();
//        //    cri.add(Condition.AND, tbHinhAnhColumns.MaSP.ToString(), Condition.EQUAL, iD);
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    tbHinhAnhCollection haCollection = haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaSP.ToString(), OrderDirection.ASC.ToString(), out total);
//        //    if (haCollection.Count > 0)
//        //        return haCollection[0];
//        //    return null;
//        //}
//        ////public static tbHinhAnhCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
//        //{
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
//        //}
//        //public static tbHinhAnhCollection GetAll()
//        //{
//        //    int total = 0;
//        //    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        //    return haDAL.Get("Where 1=1", 0, 0, tbHinhAnhColumns.MaHA.ToString(), "ASC", out total);
//        //}
//        //////public static tbHinhAnh GetByID(int iD)
//        //////{
//        //////    int total = 0;
//        //////    tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
//        ////    tbHinhAnhCollection haCollection = haDAL.Get("where " + tbHinhAnhColumns.MaHA.ToString() +
//        ////       "=" + iD.ToString(), 0, 0,tbHinhAnhColumns.MaHA.ToString(), "ASC", out total);
//        ////    if (haCollection.Count > 0)

//        ////        return haCollection[0];
//        ////    return null;
//        ////}

////        public static tbHinhAnh GetByMaSP(int iD)
////        {
////            int total = 0;
////            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
////            tbHinhAnhCollection haCollection = haDAL.Get("where " + tbHinhAnhColumns.MaSP.ToString() +
////               "=" + iD.ToString(), 0, 0, tbHinhAnhColumns.MaSP.ToString(), "ASC", out total);
////            return haCollection[0];

////        }


    }
}